<%@page import="java.util.TimeZone"%>
<%@page import="Model.Purchase.PurchaseListView"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
 long current=System.currentTimeMillis();
 long zero=(current/(1000*3600*24)*(1000*3600*24)-TimeZone.getDefault().getRawOffset())/1000;
 PurchaseListView pur = new PurchaseListView(pageContext);
 pur.request();
  String shijian = pur.get("shijian");
   switch (shijian) {
           case "0":
               shijian = "-1";
               break;
           case "1":
               shijian = String.valueOf(zero);
               break;
           case "3":
               shijian = String.valueOf(zero - (86400 * 3));
               break;
           case "7":
               shijian = String.valueOf(zero - (86400 * 7));
               break;
           case "30":
               shijian = String.valueOf(zero - (86400 * 30));
               break;
           case "365":
               shijian = String.valueOf(zero - (86400 * 365));
               break;
       }
   
    if(shijian.equals("0")){
      shijian="-1";
    }
    if(pur.get("gonggao").equals("0")){
//     pur.select("count(*) as num").where("typid=2 and state=1 and shijian >="+shijian+" and name like '%"+pur.get("materielname") +"%' and shengid like '%"+pur.get("shengid") +"%' and shiid like '%"+pur.get("shiid") +"%' and xianid like '%"+pur.get("xianid") +"%'").get_first_rows();
 pur.select("count(*) as num").where("typid=2 and state=1 and shijian >="+shijian+" and name like '%"+pur.get("materielname") +"%'").get_first_rows();
     pur.write("num");
    }else{
//     pur.select("count(*) as num").where("typid=2 and shijian >="+shijian+" and name like '%"+pur.get("materielname") +"%' and shengid like '%"+pur.get("shengid") +"%' and shiid like '%"+pur.get("shiid") +"%' and xianid like '%"+pur.get("xianid") +"%' and state= 2 or state=3").get_first_rows();
 pur.select("count(*) as num").where("typid=2 and shijian >="+shijian+" and name like '%"+pur.get("materielname") +"%' and state= 2 or state=3").get_first_rows();
     pur.write("num");
    }
%>
